import tensorflow.compat.v1 as tf

# 在Tensorflow 2.0 中，eager execution 是默认开启的。所以，需要先关闭eager execution
tf.compat.v1.disable_eager_execution()

matrix1 = tf.constant([[3, 3]])
# print(matrix1)
matrix2 = tf.constant([[2],
                       [2]])
# print(matrix2)

product = tf.matmul(matrix1, matrix2)  # matrix multiply  = np.dot(m1,m2)

# session会话的两种打开方式
sess = tf.Session()
result = sess.run(product)  # sess 中的run 每次执行的时候 都会执行run对象所包含的所有流程
print(result)
sess.close()


# method 2
with tf.Session() as sess:
    print("session ...")
    result2 = sess.run(product)
    print(result2)
